DEFINITION MODULE Time;

  CONST MinYear = 0001;       (* arbitrary limits; broad enough for  *)
        MaxYear = 9999;       (*   for most practical cases purposes *)

  TYPE Month = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);

       Date = RECORD
                da: [1..31];
                mo: Month;
                yr: [MinYear..MaxYear]
              END;

       DayType = (Sun, Mon, Tue, Wed, Thu, Fri, Sat);

  PROCEDURE IsLeapYear(yr: CARDINAL): BOOLEAN;

  PROCEDURE NumDays(d: Date): LONGCARD;
    (* NumDays returns an ordinal value for the date
       with January 1, 0001 assigned the value 1.    *)

  PROCEDURE MakeDate(n: LONGCARD; VAR d: Date);
    (* Takes an ordinal value compatible with that
       returned by NumDays and forms the corresponding
       date in d.                                      *)

  PROCEDURE DayOfWeek(d: Date): DayType;

  PROCEDURE GetSelDate(VAR d: Date; VAR abort: BOOLEAN);
    (* General routine that allows the user to select
       a date by positioning a "cursor" on the desired
       date and pressing return; if <Esc> is pressed,
       the date is left unchanged and abort becomes TRUE.

       d should be seeded with a valid date, which will
       become determine the starting date upon calling
       the procedure.                                     *)

  PROCEDURE IncDate(VAR d: Date; n: LONGCARD);
    (* Increments the date by the value n. *)

  PROCEDURE DecDate(VAR d: Date; n: LONGCARD);
    (* Decrements the date by the value n. *)

  PROCEDURE GetSysDate(VAR d: Date; VAR dayOfWeek: DayType);
    (* Reads the system clock and assigns the date to d
       and the day of the week to dayOfWeek.            *)


END Time.
